package test_0523;

public class test04_bucketSort {
    public static void main(String[] args) {
        int[] arr = new int[]{1,5,3,3,4,2,8,20,9,2};
        int max = 0;
        for (int i = 0; i < arr.length -1; i++) {
            if(arr[i] > max){
                max = arr[i];
            }
        }
        int len = arr.length - 1;
        for (int i = 0; i <= len; i++) {
            System.out.print(arr[i] +" ");
        }
        System.out.println();
        int[] arr_bucket = new int[max + 1];
        for (int i = 0; i < arr.length; i++) {
            arr_bucket[arr[i]] ++;

        }
        for (int i = 0; i <= arr_bucket.length - 1; i++) {
            if(arr_bucket[i] != 0){
                for (int j = 0; j < arr_bucket[i]; j++) {
                    System.out.print(i +" ");
                }
            }
        }


    }
}
